package com.xxxx.comment.controller;

import com.xxxx.comment.entity.dto.Result;
import com.xxxx.comment.service.IFollowService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/follow")
@Slf4j
public class FollowController {

    @Resource
    private IFollowService followService;

    @PutMapping("/{id}/{isFollow}")
    public Result follow(@PathVariable("id") Long followUserId, @PathVariable("isFollow") Boolean isFollow) {
        log.error("开始: {}", LocalDateTime.now());
        Result result = followService.follow(followUserId, isFollow);
        log.error("结束: {}", LocalDateTime.now());
        return result;
    }

    @GetMapping("/or/not/{id}")
    public Result isFollow(@PathVariable("id") Long followUserId) {
        return followService.isFollow(followUserId);
    }

    @GetMapping("/common/{userId}")
    public Result commonFollow(@PathVariable Long userId) {
        return followService.commonFollow(userId);
    }

}
